package com.example.datn.activities;

import android.os.Bundle;

import com.example.datn.DeveloperKey;
import com.example.datn.R;
import com.example.datn.manager.VideoManager;
import com.example.datn.objects.VideoObject;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
import com.google.android.youtube.player.YouTubePlayer.Provider;

public class PlayVideoActivity extends YouTubeFailureRecoveryActivity{


	VideoObject video;
	
	@Override
	protected void onCreate(Bundle bundle) {		
		super.onCreate(bundle);		
		setContentView(R.layout.play_video_full_screen);
		
		video = VideoManager.getInstance().getCurrentVideo();
		
		YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
	    youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this);	    
	}

	@Override
	public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
		if (!wasRestored) {
			player.setFullscreen(true);
		    player.cueVideo(video.videoId);
		}
	}

	@Override
	protected Provider getYouTubePlayerProvider() {
		return (YouTubePlayerView) findViewById(R.id.youtube_view);
	}

}
